package com.sxm.yiwei.adapters;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.sxm.yiwei.R;
import com.sxm.yiwei.beans.HotContentRecever;

import java.util.List;

/**
 * Created by KuKa on 2017/7/3.
 * 订单详情联系人列表（收货人）
 */

public class BookContentLinkAdapter extends BaseAdapter {
    Context context;
    List<HotContentRecever> receverList;
    public BookContentLinkAdapter(Context context,  List<HotContentRecever> receverList) {
        this.context=context;
        this.receverList=receverList;

    }

    @Override
    public int getCount() {
        return receverList.size();
    }

    @Override
    public Object getItem(int position) {
        return receverList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view;
        ViewHolder holder;
        if (convertView==null){
            view= View.inflate(context, R.layout.content_linkitem,null);
            holder = new ViewHolder();
            holder.name = (TextView) view.findViewById(R.id.bookcontent_linkname);
            holder.address = (TextView) view.findViewById(R.id.bookcontent_linkaddress);
            view.setTag(holder);
        }else {
            view = convertView;
            holder = (ViewHolder) view.getTag();
        }

        holder.name.setText("收货人"+(position+1)+": "+receverList.get(position).getConsigneeName()+" "+receverList.get(position).getConsigneeTel());
        holder.address.setText(receverList.get(position).getConsigneeAddr()+" "+receverList.get(position).getConsigneeHous()+"室");
        return view;
    }
    class ViewHolder{
        TextView name,address;
    }
}
